<?php
session_start();
if (isset($_POST['op']) && !empty($_POST['op'])){
    if(isset($_SERVER["HTTP_X_REQUESTED_WITH"]) && strtolower($_SERVER["HTTP_X_REQUESTED_WITH"])=="xmlhttprequest"){
    include '../c/config.php';
    $mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
    $openid=addslashes(trim($_POST['op']));
    $sql="select zslink,ji from `zsu_user_log` where openid='".$openid."'  limit 0,1 ";
  	$query = $mysqli->query($sql);
    $zslink='';
    $zsJi='';
  	if($query->num_rows>0){
         $getZsu=$query->fetch_assoc();
         $zslink=$getZsu['zslink'];
         $zsJi=$getZsu['ji'];
         $mysqli->query("insert into ".$tableVer."_puv(openid,theday,zslink,ji,createtime) values('".$openid."','".date("Y-m-d")."','".$zslink."','".$zsJi."','".date("Y-m-d H:i:s")."') ");
  	}else{
  		  $mysqli->query("insert into ".$tableVer."_puv(openid,theday,createtime) values('".$openid."','".date("Y-m-d")."','".date("Y-m-d H:i:s")."') ");
  	}

    $mysqli->query("insert into zsu_user_time(openid,dayid,zslink,ji,statime) values('".$openid."','".$_POST["cookieid"]."','".$zslink."','".$zsJi."','".date("Y-m-d H:i:s")."') ");

    
    $query=$mysqli->query("select id from `zsu_phone_tong` where openid='".$openid."'  limit 0,1 "); 
    if($query->num_rows>0){
        $mysqli->query("update zsu_phone_tong set pv=pv+1 where openid='".$openid."' ");
    }else{
        $query=$mysqli->query("select phone from `y1_users` where openid='".$openid."'  limit 0,1 "); 
        if($query->num_rows>0){
          $getUser=$query->fetch_assoc();
          $mysqli->query("insert into zsu_phone_tong(openid,zslink,phone,pv) values('".$openid."','".$zslink."','".$getUser['phone']."', 1) ");
        }
    }

    echo 2;
     
   
    $mysqli->close();
   }
}
?>